package com.hmall.search.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.order.exception.BaseException;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auth: wan
 * @Desc: 搜索栏控制器
 * @Date: 2023/4/19 下午 4:51
 */
@RestController
@RequestMapping("/search")
@Slf4j
public class SearchController {

	@Autowired
	private SearchService service;

	@PostMapping("filters")
	public PageDTO<ItemDoc> getSearchQuery(@RequestBody RequestParams requestParams){
		PageDTO<ItemDoc> items = service.getSearchQuery(requestParams);
		log.error(requestParams.toString());
		return items;
	}

    @PostMapping("/list")
    public PageDTO list(@RequestBody RequestParams params){
        return service.search(params);
    }

}
